import { TabHeightService } from './../../../shared/service/tab-height.service';
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { Tabs } from 'src/app/shared/components';
import { Router } from '@angular/router';
import { HomeContainerService } from '../../service';

@Component({
  selector: 'app-home-container',
  templateUrl: './home-container.component.html',
  styleUrls: ['./home-container.component.less'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class HomeContainerComponent implements OnInit {
  switchLink: string = '/home/recommend';
  title: string = 'pinxixi';
  tabs: Tabs[] = [];
  top!: number;
  bottom!: number;
  constructor(
    private router: Router,
    private homeContainerService: HomeContainerService,
    private tabHeight: TabHeightService
  ) {}
  ngOnInit(): void {
    this.tabs = this.homeContainerService.getTabs();
    this.switchLink = this.router.url;
  }
  ngAfterViewInit(): void {
    this.bottom = this.tabHeight.FooterTabHeight;
    this.top = this.tabHeight.TopTabHeight;
  }
  // @confirmable('确定吗？')
  async handelTabClick(selected: string) {
    await this.router.navigate(['home', selected.link]);
    this.switchLink = this.router.url;
  }
}
